﻿using System;

namespace FDEE.Model
{
    public class MYRebarRecord : RebarBase
    {

        public int L, LapLength, Phi, hook;

        public MYRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            int l, int lapLength, int phi, int quantity, eShapeType shapeConfig) 
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig)
        {
            ShapeConfg = shapeConfig;
            LapLength = lapLength; //主筋接入承台内长度
            Phi = phi;              //⚪筋外边直径 
            L = l;                  //钢筋总长，含搭接长度            
            
        }

        public override void SetLength()
        {
            Length = (Math.Round(((Phi - Convert.ToInt32(Diameter)) * Math.PI + LapLength) * 0.001, 3, MidpointRounding.AwayFromZero)) ;
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MY长度计算异常，请查找原因！");
            }
        }
    }

    public class MYWithFormulaRebarRecord : RebarBase
    {

        public int L, LapLength, Phi, hook;

        public MYWithFormulaRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            int l, int lapLength, int phi, int quantity, eShapeType shapeConfig)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig)
        {
            ShapeConfg = shapeConfig;
            LapLength = lapLength; //主筋接入承台内长度
            Phi = phi;              //⚪筋外边直径 
            L = l;                  //钢筋总长，含搭接长度            
            Formula = "L=" + (L * 0.001).ToString("0.000") + "m,Φ=" + (phi * 0.001).ToString("0.000") + "m";
            Formula += "\\P Lapping=" + (lapLength * 0.001).ToString("0.000");
        }

        public override void SetLength()
        {
            Length = double.Parse((L * 0.001).ToString("0.000"));//(Math.Round(((Phi - Convert.ToInt32(Diameter)) * Math.PI + LapLength) * 0.001, 3, MidpointRounding.AwayFromZero));
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MY长度计算异常，请查找原因！");
            }
        }
    }

}
